import React from 'react'
import memoryUtils from '../../utils/memoryUtils'
import { Redirect,Route,Switch } from 'react-router-dom'
import { Layout } from 'antd';
import LeftSider from '../../components/LeftSider'
import Header from '../../components/Header'

import Home from '../home/Home'
import Category from '../category/Category'
import Product from '../product/Product'
import Role from '../role/Role'
import User from '../user/User'
import Bar from '../echarts/Bar'
import Line from '../echarts/Line'
import Pie from '../echarts/Pie'
import Order from '../order/Order'



const { Footer, Sider, Content } = Layout;

export default class Admin extends React.Component {
    constructor(props) {
        super(props)
        this.state = {}
    }

    render() {
        const user = memoryUtils.user
        if (!user.username) {
            return <Redirect to='/login'></Redirect>
        }
        return (
            <Layout style={{ height: '100%' }}>
                <Sider>
                    <LeftSider />
                </Sider>
                <Layout>
                    <Header>Header</Header>
                    <Content style={{ backgroundColor: '#fff',margin:'20px 10px' }}>
                        <Switch>
                            <Route path='/home' component={Home}></Route>
                            <Route path='/category' component={Category}></Route>
                            <Route path='/product' component={Product}></Route>
                            <Route path='/user' component={User}></Route>
                            <Route path='/role' component={Role}></Route>
                            <Route path='/echarts/bar' component={Bar}></Route>
                            <Route path='/echarts/line' component={Line}></Route>
                            <Route path='/echarts/pie' component={Pie}></Route>
                            <Route path='/order' component={Order}></Route>
                            <Redirect to='/home'></Redirect>
                        </Switch>
                    </Content>
                    
                    <Footer
                        style={{ textAlign: 'center', color:'#ccc'}}>
                        人生在世,短短数十载,只求问心无愧!!!
                        </Footer>
                </Layout>
            </Layout>
        )
    }
}